package com.ninth_group.controller;

import com.ninth_group.constant.UDConstants;
import com.ninth_group.result.R;
import com.ninth_group.utils.HBaseServiceUtil;
import com.ninth_group.utils.UpToHiveUtil;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 上传数据到Hive
 */
@RestController
@RequestMapping("/up")
public class UploadDataController {
    @Resource
    private UpToHiveUtil up;

    @GetMapping
    public R uploadData() {
        // 城市基本信息  localPath, hdfsPath, tableName
        up.addDate(
                UDConstants.CITY_BASE_INFO_CLASSPATH,
                UDConstants.HDFS_PATH,
                UDConstants.CITY_BASE_INFO_TB);
        // 24小时天气数据
        up.addDate(
                UDConstants.FORECAST_24H_CLASSPATH,
                UDConstants.HDFS_PATH,
                UDConstants.FORECAST_24H_TB);
        // 7天天气数据
        up.addDate(
                UDConstants.FORECAST_7D_CLASSPATH,
                UDConstants.HDFS_PATH,
                UDConstants.FORECAST_7D_TB);
        // 省份天气信息
        up.addDate(
                UDConstants.PCWI_CLASSPATH,
                UDConstants.HDFS_PATH,
                UDConstants.PCWI_TB);
        return R.ok("ok");
    }
}
